import { createSlice } from '@reduxjs/toolkit'

const Storage = {
    setStorage(key, value) {
        localStorage.setItem(key, JSON.stringify(value))
    },
    getStorage(key) {
        return JSON.parse(localStorage.getItem(key))
    }
}
const shop = createSlice({
    name: "shop",
    initialState: {
        shoplist: Storage.getStorage('shoplist') || []
    },
    reducers: {
        addShop(state, { payload }) {
            Storage.setStorage('shoplist', payload)
        },

    }
})

export const { addShop } = shop.actions
export default shop.reducer